
import systemApi from "@/api/chooseSystem/index";
import store from '@/store'
/**
 * 
 * @param {sting} virtualSystemNo  //子系统标识
 * @param {sting} path   //子系统页面地址
 * @param {sting} code   //按钮的标识
 * @returns 
 */
export async function getRoleFunction(path, code) {
  let userType = sessionStorage.getItem('userType')
  let virtualSystemNo = sessionStorage.getItem('virtualSystemNo')
  // if (userType == 'ADMIN') {
  //   return true
  // }
  let menuNoList = store.state.app.menuNoList;
  let menu = menuNoList.find(item => {
    return item.path == path
  })
  if (menu && menu.menuNo && virtualSystemNo) {
    let { data: functionList } = await systemApi.getRoleFunctionAll(virtualSystemNo, menu.menuNo);
    let rut = functionList.find(item => { return item.code == code });
    return rut ? true : false;
  } else {
    return true;
  }
}
